(function() {
    const response = {
        data: {
            type: "page",
            title: "登录",
            body: [
            //     {
            //     type: 'form',
            //     mode: 'horizontal',
            //     api: {
            //         method: 'post',
            //         url:'/api/users/login',
            //         adaptor: function (payload, response) {
            //             console.log("payload=")
            //             console.log("payload=", payload)
            //             console.log("response=", response)
            //             if (payload.code === 20000) {
            //                 localStorage.setItem("token", payload.data.accessToken);
            //                 localStorage.setItem("avatar", payload.data.userInfo.imgUrl);
            //                 localStorage.setItem("username", payload.data.userInfo.username);
            //                 location.href = '/index.html';
            //             }
            //             return {
            //                 ...payload,
            //                 status: payload.code === 20000 ? 0 : payload.code
            //             };
            //         },
            //     },
            //
            //     body: [
            //         {
            //             label: '用户名',
            //             type: 'input-text',
            //             name: 'username'
            //         },
            //         {
            //             label: '密码',
            //             type: 'input-password',
            //             name: 'password'
            //         }
            //     ]
            // },
            {
                "type": "tabs",
                "tabsMode": "sidebar",
                "sidePosition": "left",
                "tabs": [
                    {
                        "title": "登录",
                        "body": {
                            type: 'form',
                            title: "登录信息",
                            mode: 'horizontal',
                            api: {
                                method: 'post',
                                url:'/api/users/login',
                                adaptor: function (payload, response) {
                                    console.log("payload=")
                                    console.log("payload=", payload)
                                    console.log("response=", response)
                                    if (payload.code === 20000) {
                                        localStorage.setItem("token", payload.data.token);
                                        localStorage.setItem("avatar", payload.data.userInfo.imgUrl);
                                        localStorage.setItem("username", payload.data.userInfo.username);
                                        location.href = '/index.html';
                                    }
                                    return {
                                        ...payload,
                                        status: payload.code === 20000 ? 0 : payload.code
                                    };
                                },
                            },

                            body: [
                                {
                                    label: '用户名',
                                    type: 'input-text',
                                    name: 'username',
                                    "required": true
                                },
                                {
                                    label: '密码',
                                    type: 'input-password',
                                    name: 'password',
                                    "required": true
                                },
                                {
                                    type: "checkbox",
                                    name: "rememberMe",
                                    label: "记住登录"
                                }
                            ]
                        },
                        "icon": "fa fa-user-check"
                    },
                    {
                        "title": "注册",
                        "body": {
                            type: 'form',
                            title: "用户信息",
                            mode: 'horizontal',
                            api: {
                                method: 'post',
                                url:'/api/users/register',
                                adaptor: function (payload, response) {
                                    if (payload.code === 20000) {
                                    }
                                    return {
                                        ...payload,
                                        status: payload.code === 20000 ? 0 : payload.code
                                    };
                                },
                            },

                            body: [
                                {
                                    label: '用户名',
                                    type: 'input-text',
                                    name: 'username'
                                },
                                {
                                    label: '密码',
                                    type: 'input-password',
                                    name: 'password'
                                },
                                {
                                    label: '邮箱',
                                    type: 'input-email',
                                    name: 'email'
                                }
                            ]
                        },
                        "icon": "fa fa-id-card"
                    },
                    {
                        "title": "微信登录",
                        "body": [
                            "请扫描二维码登录",
                            {
                            "type": "qr-code",
                            "codeSize": 128,
                            "value": "https://www.baidu.com"
                        }],
                        "icon": "fa fa-weixin"
                    }
                ]
            }
            ]
        },
        status: 0
    }

    window.jsonpCallback && window.jsonpCallback(response);
})();
